package com.block.account.service.impl;

import com.block.account.model.dto.EntryAccountDTO;
import com.block.db.entity.AccountItemChannleHis;
import com.block.db.entity.AccountItemProductHis;
import com.block.db.mapper.AccountItemProductHisMapper;
import com.block.account.service.IAccountItemProductHisService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * <p>
 * 产品账户流水表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-02-02
 */
@Service
public class AccountItemProductHisServiceImpl extends ServiceImpl<AccountItemProductHisMapper, AccountItemProductHis> implements IAccountItemProductHisService {

    @Override
    public boolean saveProductHisInfo(EntryAccountDTO entryAccountDTO) {

        AccountItemProductHis itemHis = new AccountItemProductHis();
        itemHis.setDateInfo(LocalDate.now().toString());
        itemHis.setAccountId(Integer.valueOf(entryAccountDTO.getItemAccountId()));
        itemHis.setProductId(entryAccountDTO.getItemAccountKey());
        itemHis.setProductName(entryAccountDTO.getItemAccountName());

        itemHis.setActionType(entryAccountDTO.getActionType());

        itemHis.setChangeAmount(entryAccountDTO.getChangeAmount());
        itemHis.setOriginAmount(entryAccountDTO.getOriginAmount());
        itemHis.setCurrentAmount(entryAccountDTO.getCurrentAmount());

        itemHis.setMainAccountId(entryAccountDTO.getMainAccountId());
        itemHis.setMainAccountName(entryAccountDTO.getMainAccountName());

        itemHis.setDataId(entryAccountDTO.getRecordId());
        itemHis.setOperatorId(entryAccountDTO.getOperatorId());
        itemHis.setOperatorName(entryAccountDTO.getOperatorName());

        boolean saveRes = this.save(itemHis);

        return saveRes;
    }
}
